<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('公司列表')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
</head>
<body class="gray-bg">
<form id="user-form">
    <input type="hidden" id="compID" name="compID">
<div class="ui-layout-west">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-grid"></i> 公司组织机构
            </div>
            <div class="box-tools pull-right">
                <a type="button" class="btn btn-box-tool" href="#" onclick="dept()" title="管理部门"><i
                        class="fa fa-edit"></i></a>
                <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i
                        class="fa fa-chevron-up"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i
                        class="fa fa-chevron-down"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i
                        class="fa fa-refresh"></i></button>
            </div>
        </div>
        <div class="ui-layout-content">
            <div id="tree" class="ztree"></div>
        </div>
    </div>
</div>

<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <div class="select-list">
                        <ul>
                            <li>
                                公司编号：<input type="text" name="compCode"/>
                            </li>
                            <li>
                                公司名称：<input type="text" name="title"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="jinpeng:company:add">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="jinpeng:company:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>
</div>
</form>



<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>


<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('jinpeng:company:edit')}]];
    var detailFlag = [[${@permission.hasPermi('jinpeng:company:detail')}]];

    var prefix = ctx + "company";
    $(function () {
        var panehHidden = false;
        if ($(this).width() < 800) {
            panehHidden = true;
        }
        $('body').layout({ initClosed: panehHidden, west__size: 350 });
        queryCompanyTree();
        queryCompanyList();
    });

    function queryCompanyList() {
        var options = {
            code: "compID",
            uniqueId: "compID",
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove/{id}",
            detailUrl: prefix + "/detail/{id}",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            height :$(window).height() - 120,
            sortOrder: "desc",
            modalName: "公司",
            columns: [{
                checkbox: true
            }, {
                field: 'compCode',
                title: '公司编号',
            },
                {
                    field: 'compCode',
                    title: '公司代码'
                },
                {
                    field: 'compGroupName',
                    title: '集团名称'
                },
                {
                    field: 'title',
                    title: '公司名称',
                    width: '200',
                    sortable: true
                },
                {
                    field: 'compAbbr',
                    title: '公司简称'
                },
                {
                    field: 'compGradeName',
                    title: '公司级别'
                },
                {
                    field: 'compTypeName',
                    title: '公司类型'
                },
                {
                    field: 'industuName',
                    title: '所属行业'
                },
                {
                    field: 'compAreaName',
                    title: '公司区域'
                },
                {
                    field: 'adminName',
                    title: '上级公司'
                },
                {
                    field: 'lawyer',
                    title: '法人代表'
                },
                {
                    field: 'address',
                    title: '公司地址'
                },
                {
                    field: 'regAddress',
                    title: '注册地址'
                },
                {
                    field: 'tel',
                    title: '联系电话'
                },
                {
                    field: 'postCode',
                    title: '邮政编码'
                },
                {
                    field: 'webSite',
                    title: '公司网站'
                },
                {
                    field: 'socialcreCode',
                    title: '统一社会信用代码'
                },
                {
                    field: 'enterpriseQuafic',
                    title: '企业资质'
                },
                {
                    field: 'companyprofile',
                    title: '公司简介'
                },
                {
                    field: 'effectDate',
                    title: '成立日期'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.compID + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.compID + '\')"><i class="fa fa-search"></i>详细</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    }

    function queryCompanyTree() {
        var url = ctx + "jinpeng/treeData";
        var options = {
            url: url,
            expandLevel: 2,
            onClick: zOnClick
        };
        $.tree.init(options);

        function zOnClick(event, treeId, treeNode) {
            $("#compID").val(treeNode.id);
            $.table.search();
        }
    }
</script>

</body>
</html>